package com.wu.service.impl;

import com.wu.bean.User;
import com.wu.dao.UserDao;
import com.wu.dao.impl.UserDaoImpl;
import com.wu.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {
    UserDao userDao=new UserDaoImpl();
    @Override
    public void RegistUser(User user) {
        userDao.saveUser(user);
    }

    @Override
    public User Login(User user) {

        return userDao.queryUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existsUssername(String username) {
        if(userDao.queryUserByUserName(username)==null)
            return false;
        else
            return true;
    }
    @Override
    public User queryUsername(String username) {
     return userDao.queryUserByUserName(username);
    }

    @Override
    public List<User> queryUserAll() {
        return userDao.queryUserAll();
    }

    @Override
    public List<User> queryUserNameLike(String username) {
        return userDao.queryUserNameLike(username);
    }

    @Override
    public int DeleteUser(int id) {
        return userDao.DeleteUser(id);
    }

    @Override
    public int UpdateUserPassword(String username, String password) {
        return userDao.UpdateUserPassword(username,password);
    }

    @Override
    public int UpdateUser(User user) {
        return userDao.UpdateUser(user);
    }
}
